/*
 * UMediaSource.h
 *
 *  Created on: 2020年3月29日
 *      Author: chuanjiang.zh
 */

#ifndef UMEDIASOURCE_H_
#define UMEDIASOURCE_H_

#include "UMediaFormat.h"
#include "UMediaPacket.h"


class DLLEXPORT UMediaSink
{
public:
    virtual ~UMediaSink() {}

    virtual void onMediaFormat(const UMediaFormat& fmt) =0;

    virtual void onMediaPacket(UMediaPacket& pkt) =0;

    virtual void onMediaEvent(int event) =0;

};

class DLLEXPORT UMediaSource
{
public:
	virtual ~UMediaSource() {}

	virtual int open(const char* url, const char* params) =0;
	virtual void close() =0;
	virtual bool isOpen() =0;

	virtual const char* getUrl() =0;

	virtual bool getMediaFormat(UMediaFormat& fmt) =0;

	virtual int startStream() =0;

	virtual int pauseStream() =0;

	virtual void stopStream() =0;

	virtual int getState() =0;


	virtual bool addSink(UMediaSink* pSink) =0;

	virtual void removeSink(UMediaSink* pSink) =0;

	virtual void removeSinks() =0;

	virtual size_t getSinkCount() =0;


	virtual int forceKeyFrame() =0;

	/**
	 * 获取时长, 单位毫秒
	 */
	virtual int getDuration() = 0;


	virtual bool setScale(float scale) = 0;

    virtual float getScale() =0;


	virtual bool isSeekable() = 0;

	/**
	 * 定位, 单位微秒
	 */
	virtual bool seek(int64_t pos) = 0;

	/**
	 * 获取当前时间, 单位微秒
	 */
	virtual int64_t getTime() = 0;

};



#endif /* UMEDIASOURCE_H_ */
